package com.magnificent.atlantis.client.data.settings;

import com.magnificent.atlantis.client.data.configuration.ServerConfiguration;
import com.magnificent.atlantis.common.entity.ServerUser;

import javax.xml.bind.annotation.XmlAttribute;

/**
 * User: Babanin
 * Date: 19.02.2009
 * Time: 13:00:52
 */
public class User implements Comparable<User> {
    private long id;

    private String name;
    private String surname;

    private int confugurationId;

    public User() {
    }

    public User(ServerUser serverUser, ServerConfiguration configuration) {
        setId(serverUser.getId());
        setName(serverUser.getName());
        setSurname(serverUser.getSurname());
        setConfugurationId(configuration.getId());
    }

    @XmlAttribute()
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @XmlAttribute()
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlAttribute()
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    @XmlAttribute()
    public int getConfugurationId() {
        return confugurationId;
    }

    public void setConfugurationId(int confugurationId) {
        this.confugurationId = confugurationId;
    }

    @Override
    public String toString() {
        return surname + " " + name;
    }

    public int compareTo(User o) {
        return -o.getSurname().compareTo(getSurname());
    }
}
